]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
overviewControls: Use adjustment to control layout
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 30 Dec 2020 20:32:03 +0000 (17:32 -0300)
committerMarge Bot <marge-bot@gnome.org>
Thu, 11 Feb 2021 15:50:31 +0000 (15:50 +0000)
Right now, the adjustment is fixed at ControlsState.WINDOW_PICKER,
but soon it will be propagated to ViewSelector to control the
transitions.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>

js/ui/overviewControls.js

index d31c5b96ca913bf964ea7977b8943937a9045127..4f0751d45f25b2e19e70bff1e7d5aaef6176cce7 100644 (file)
@@ -6,14 +6,23 @@ const { Clutter, GObject, St } = imports.gi;
 const Dash = imports.ui.dash;
 const ViewSelector = imports.ui.viewSelector;
 
+var ControlsState = {
+    HIDDEN: 0,
+    WINDOW_PICKER: 1,
+    APP_GRID: 2,
+};
+
 var ControlsManagerLayout = GObject.registerClass(
 class ControlsManagerLayout extends Clutter.BoxLayout {
-    _init(searchEntry, viewSelector, dash) {
+    _init(searchEntry, viewSelector, dash, stateAdjustment) {
         super._init({ orientation: Clutter.Orientation.VERTICAL });
 
+        this._stateAdjustment = stateAdjustment;
         this._searchEntry = searchEntry;
         this._viewSelector = viewSelector;
         this._dash = dash;
+
+        stateAdjustment.connect('notify::value', () => this.layout_changed());
     }
 
     vfunc_set_container(container) {
@@ -46,9 +55,18 @@ class ControlsManagerLayout extends Clutter.BoxLayout {
         availableHeight -= dashHeight + spacing;
 
         // ViewSelector
+        const initialBox = new Clutter.ActorBox();
+        initialBox.set_origin(0, 0);
+        initialBox.set_size(width, height);
+
         childBox.set_origin(0, searchHeight + spacing);
         childBox.set_size(width, availableHeight);
-        this._viewSelector.allocate(childBox);
+
+        const page = this._viewSelector.getActivePage();
+        const progress = page === ViewSelector.ViewPage.SEARCH
+            ? 1 : Math.min(this._stateAdjustment.value, 1);
+        const viewSelectorBox = initialBox.interpolate(childBox, progress);
+        this._viewSelector.allocate(viewSelectorBox);
     }
 });
 
@@ -93,6 +111,13 @@ class ControlsManager extends St.Widget {
             upper: workspaceManager.n_workspaces,
         });
 
+        this._stateAdjustment = new St.Adjustment({
+            actor: this,
+            value: ControlsState.WINDOW_PICKER,
+            lower: ControlsState.HIDDEN,
+            upper: ControlsState.APP_GRID,
+        });
+
         this._nWorkspacesNotifyId =
             workspaceManager.connect('notify::n-workspaces',
                 this._updateAdjustment.bind(this));
@@ -105,7 +130,7 @@ class ControlsManager extends St.Widget {
         this.add_child(this.viewSelector);
 
         this.layout_manager = new ControlsManagerLayout(searchEntryBin,
-            this.viewSelector, this.dash);
+            this.viewSelector, this.dash, this._stateAdjustment);
 
         this.connect('destroy', this._onDestroy.bind(this));
     }